/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.view.canvas.MouseHandlers;

import java.awt.event.MouseEvent;
import simplemetrosystem.view.MetroFrame;
import simplemetrosystem.view.canvas.CanvasModel;

/**
 *
 * @author Eric Qian
 */
public class RemoveHandler extends BasicMouseHandler {

    public RemoveHandler(MetroFrame frame) {
        super(frame);
        this.frame = frame;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);

        CanvasModel model = CanvasModel.getInstance();
        int x = MouseTrans.X(e.getX());
        int y = MouseTrans.Y(e.getY());
        model.clear(x, y);
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        super.mouseMoved(e);
        CanvasModel model = CanvasModel.getInstance();
        int x = MouseTrans.X(e.getX());
        int y = MouseTrans.Y(e.getY());
        if (model.isEmpty(x, y)) {
            frame.setCursor(defaultCursor);
        } else {
            frame.setCursor(handCursor);
        }
    }
    private MetroFrame frame;
}
